//
//  UIFont+AP.swift
//  APExtensions
//
//  Created by jianbo.pei on 2023/6/25.
//

import Foundation
import UIKit

extension UIFont: APCompatible {}
public extension APBase where Base: UIFont {
    enum FontName: String {
        case regular = "PingFangSC-Regular"
        case medium = "PingFangSC-Medium"
    }
    
    private static func font(name: FontName, size: CGFloat) -> UIFont {
        if let font = UIFont(name: name.rawValue, size: size) {
            return font
        } else {
            return UIFont.systemFont(ofSize: size, weight: .regular)
        }
    }
    
    static func regular(_ fontSize: CGFloat) -> UIFont {
        font(name: .regular, size: fontSize)
    }
    
    static func medium(_ fontSize: CGFloat) -> UIFont {
        font(name: .medium, size: fontSize)
    }
}
